package exercise7;

public class Exercise12_01 {
    public static void main(String []args){
        System.out.println("请输入计算式：");

        int num1;
        int num2;
        int result;


        try {
            num1=Integer.parseInt(args[0]);
        }
        catch (NumberFormatException e1){
            System.out.println("Wrong Input: " + args[0]);
            return;
        }

        try {
            num2=Integer.parseInt(args[2]);
        }
        catch (NumberFormatException e2){
            System.out.println("Wrong Input: " + args[2]);
            return;
        }


        switch (args[1].charAt(0)) {
            case '+': result = num1 + num2;
                break;
            case '-': result = num1 - num2;
                break;
            case '*': result = num1 * num2;
                break;
            case '/': result = num1 / num2;
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + args[1].charAt(0));
        }

        System.out.println(args[0] + " " + args[1] + " " + args[2] + " = " + result);

    }
}
